﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Annotations;
using System.Windows.Input;
using SnakeGame.Views;
using System.Windows.Media;

namespace SnakeGame.ViewModels
{
    public class AnswerPageViewModel
    {
        private QuestionFrame _qFrame;
        public string Answer { get; set; }
        public string Title { get; set; }
        public int Step { get; set; }
        public ICommand GoCommand { get; set; }
        public Brush TextColor { get; set; }


        public AnswerPageViewModel()
        {
            GoCommand = new RelayCommand(OnGoCommand);

        }

        private void OnGoCommand(object obj)
        {
            _qFrame.Window.Close();
        }

        public void Initialize(QuestionFrame qFrame, bool isWin)
        {
            _qFrame = qFrame;
            
            // set return value
            qFrame.Window.IsWin = isWin;

            if (isWin)
            {
                Title = "You are right!!!";
                Step = qFrame.QuestionItem.Win;
                TextColor = Brushes.Green;
                Answer = qFrame.SelectedQuestion.Answer;
            }
            else
            {
                Title = "You are wrong!!!";
                Step = qFrame.QuestionItem.Lose;
                TextColor = Brushes.Red;
                Answer = "???";

            }
        }
    }
}
